home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Graphics / SMan / WarpOS / Source / ULP3.asm < prev    next >
Encoding:
Assembly Source File  |  2001-03-26  |  3.5 KB  |  141 lines

  1.  
  2. #Comments from ULP2.asm in most cases apply here as well.
  3.  
  4.     .global    @__UseLibP3
  5.     .text
  6.     .sdreg    r2
  7.     .global    _UseLibP3
  8.     .align    4
  9. _UseLibP3:
  10.     mflr    r11
  11.     stw    r11,8(r1)    #Save return address
  12.     stwu    r1,-96(r1)      #Save stack pointer
  13.     fmr    f16,f1        #Transfer yrel from f1 to f16
  14.     lwz    r24,_MaxCnt(r2)        #MaxCnt in r24.
  15.     lwz    r25,_LPixelBuf(r2)    #Get Location of LPixelBuf
  16.     lwz    r27,_ColorTable32(r2)    #Start of color table
  17.     lwz    r28,_BPP(r2)             #Number bytes per pixel
  18.     lfd    f25,_Factor(r2)    #Get Factor into f25
  19.     lfd    f22,_Two(r2)    #Get Two into f22 as constant
  20.     lfd    f23,_Limit(r2)    #Get Limit into f23 as constant
  21.     fadd    f14,f22,f22    #f14 is 4.
  22.     fadd    f14,f14,f22    #f14 is 6.
  23.     fdiv    f14,f14,f22    #f14 is 3.
  24.  
  25. #The above could have been done with a global definition of 3.000.
  26.  
  27.     li    r30,0        #xtemp = 0.
  28.     fsub    f15,f22,f22    #(float)xtemp = 0.
  29.     lfd    f10,_XCenter(r2)#f10 = XCenter
  30.     fsub    f15,f15,f10    #xRel = xRel - XCenter
  31.     fdiv    f18,f15,f25    #xRel = xRel/Factor
  32.  
  33.     lfd    f21,_DX(r2)    #Get the real value of Delta x.
  34.     lwz    r29,_RightEdge(r2)
  35. Start:
  36.     fmr    f15,f18        #Initial value of Zr is xRel
  37.  
  38. #  The following line was moved before rather than after fmr f17,f16
  39. #  to give the fpu a break.
  40.     li    r23,1        #Initialize CurCnt = 1
  41.     fmr    f17,f16        #yRel into f17 as initial Zi.
  42.     b    l3        #Check to see if to MaxCnt
  43. l2:
  44.     fmul    f24,f15,f15    #Zr2 in f24
  45.     fmul    f4,f17,f17    #Zi2 = Zi*Zi
  46.     fadd    f19,f24,f4      #Zr2 + Zi2 -> f19
  47.     fcmpu    cr0,f19,f23    #Compare with Limit in f23.
  48.     ble    cr0,l6
  49.  
  50. #The following section is not very time-critical as it is only reached once.
  51. #for each pixel
  52.     cmpwi    cr0,r28,2    #See if BPP < 2
  53.     blt    cr0,l8
  54. l7:
  55.     slwi    r10,r23,2    #4 times CurCnt for offset in ColorTable32
  56.     add    r26,r27,r10    #Find location of pixel color in ColorTable32
  57.     lwz    r11,0(r26)    #Get ARGB from ColorTable
  58.     stw    r11,0(r25)    #Store color in LPixelBuf
  59.     addi    r25,r25,4    #Point to next location in LPixelBuf
  60.     b    l1
  61. l8:    andi.    r3,r23,65535    #Prep for PlotIt as UWORD
  62.     bl    _PlotIt
  63. l9:    b    l1
  64.  
  65. #    Note that l6 - l3 is the most time sensitive part.
  66. #    It is important that no two consecutive instructions have inputs
  67. #    on the second that depend on the output of the previous.
  68. l6:
  69.     fmul    f20,f4,f14    #This is Zi2*3
  70.     addi    r23,r23,1       #Increment CurCnt
  71.  
  72.     fmul    f26,f24,f14    #Zr2*3    #Better here than below!
  73.  
  74.     fsub    f20,f24,f20    #Zr3 = Zr2 - 3*Zi2
  75.     fsub    f26,f26,f4    #3*Zr2 - Zi2
  76.  
  77.     fmul    f24,f20,f15    #Zr3 = (Zr2 - 3*Zi2)*Zr -> Zr2 = f24.
  78.  
  79.     fmul    f17,f26,f17    #Zi*(3*Zr2 - Zi2) -> Zi
  80.  
  81.     fadd    f15,f18,f24     #New Zr = xRel + Zr2
  82.  
  83.     fadd    f17,f16,f17    #Zi = Zi + yRel
  84.  
  85. l3:
  86.     cmpw    cr0,r23,r24    #See if CurCnt < MaxCnt
  87.     blt    cr0,l2        #Repeat until MaxCnt reached
  88.  
  89.     cmpwi    cr0,r28,2    #See if BPP < 2
  90.     blt    cr0,l11
  91. l10:
  92.  
  93.     lis    r12,4
  94.     addi    r12,r12,-4
  95.     add    r26,r27,r12    #Find location of pixel color
  96.     lwz    r11,0(r26)      #Get color
  97.  
  98.     stw    r11,0(r25)    #Store color in LPixelBuf
  99.     addi    r25,r25,4    #Point to next pixel in buffer
  100.     b    l1        #Was l12
  101. l11:
  102.     lis    r11,1
  103.     addi    r3,r11,-1    # ffff into r3 for PlotIt
  104.     bl    _PlotIt
  105. l1:
  106.     fadd    f18,f18,f21    #Find new value of xRel (xRel = xRel + DX).
  107.     addi    r30,r30,1    #Increment xtemp.
  108.     cmpw    cr0,r30,r29    #See if to RightEdge
  109.  
  110.     blt    cr0,Start    #Repeat until row is done.
  111.     stw    r25,_LPixelBuf(r2)  #New location in long pixel buffer
  112.     addi    r1,r1,96        #Balance Stack pointer
  113.     lwz    r11,8(r1)    #Get return address
  114.     mtlr    r11
  115.     fmr    f1,f20
  116.  
  117.     blr
  118.     .type    _UseLibP3,@function
  119.     .size    _UseLibP3,$-_UseLibP3
  120.  
  121.     .global    _MaxCnt
  122.     .global    _RightEdge
  123.     .global    _XCenter
  124.     .global    _Factor
  125.     .global    _Limit
  126.     .global    _Two
  127.     .global _Three
  128.     .global    _Color
  129.     .global    _LPixelBuf
  130.     .global    _ColorTable32
  131.     .global    _BPP
  132.     .global    _DX
  133.     .global    _PlotIt
  134.     .global    @__PlotIt
  135.  
  136. #    .tocd
  137. #    .align    3
  138. #l13:
  139. #    .long    0x43300000,0x80000000
  140. #l14:    .word    0
  141. #l15:    .word    0